<? 
	session_start();
	include ('../parametros/bd.php');
	
	$conect = new conector_pg();
	$conect-> conectar();
	// query 
	$sql="select * from categorias order by descripcion"; 
	// Ejecutas la consulta y guardas el resultado en una variable 
	$result=$conect->consultar($sql);
		if (!$result)
		 {
			echo 'error en la consulta'	;
			exit;
		 } 

$categoria_datos=array();
$ind=0;		 
while ($cate= pg_fetch_array($result, null, PGSQL_ASSOC)){
	$categoria_datos[$ind]=$cate;
	$ind = $ind + 1;
}		 
?>
<?php if (isset($_SESSION['logged_in'])) 
	   { 
	   	if ($_SESSION['admin'] == 1)
	   	{ 
?>
<html>
<head>
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" />
<link href="../css/imageMenu.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="XoR-main">
			<div class="XoR-sheet">
				<div class="XoR-sheet-tl"></div>
				<div class="XoR-sheet-tr"></div>
				<div class="XoR-sheet-bl"></div>
				<div class="XoR-sheet-br"></div>
				<div class="XoR-sheet-tc"></div>
				<div class="XoR-sheet-bc"></div>
				<div class="XoR-sheet-cl"></div>
				<div class="XoR-sheet-cr"></div>
				<div class="XoR-sheet-cc"></div>
				<div class="XoR-sheet-body">
					<div class="XoR-header">
						<div class="XoR-header-center">
							<div class="XoR-header-png"></div>
							<div class="XoR-header-jpeg"></div>
						</div>
						<div class="XoR-logo">
							<h1 id="name-text" class="XoR-logo-name"><a href="./index.html">Libreria TAI</a></h1>
							<h2 id="slogan-text" class="XoR-logo-text">Primera Libreria Online del Paraguay</h2>
						</div>
					</div>
<h1 id="tituloNaranja2">Consulta de Categorias</h1>
<table> 
  <tr>
    <th id="labelLogin">Descripcion</th>
    <th id="labelLogin">Acciones</th>
  </tr>

  	<? 
  	foreach ($categoria_datos as $ind => $valor) {?>
  	<tr> 
		<td id="searchForm"><?echo $valor['descripcion']?> </td>
		<td>
		<? 
			$_SESSION['idcategoria'] =$valor['idcategoria'];
			$_SESSION['url2'] = ('edicioncategoria.php'.'?id='.$_SESSION['idcategoria']);
        ?>
			<a id="submitLogin" href="<?php echo $_SESSION['url2']?>">Editar</a>			 
        </td>
	</tr>
	<?}?>	
</table>


<a id="submitLogin"  href="nuevacategoria.php"> Nueva Categoria </a>
<br>
<a id="labelLogin" href="indexadmin.php"> Regresar al listado </a>
<?php 
	   	}
?>
<a href="../login/logout.php?signature=<?php echo $_SESSION['signature']; ?>
">Logout</a><br /><?php } 
?>
<div class="cleared"></div>
					<div class="XoR-footer">
						<div class="XoR-footer-body">
							<div class="XoR-footer-text">
								<p>Copyright 2011, XoR Company. All Rights Reserved.</p>
							</div>
							<div class="cleared"></div>
						</div>
					</div>
					<div class="cleared"></div>
				</div>
			</div>
			<div class="cleared"></div>
			<p class="XoR-page-footer">Powered by <a href="http://xor.net/">XoR.org</a> </p>
		</div>
</body>
</html>


